package com.example.ntweixin.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.example.ntweixin.entity.WeixinPublic;
import com.example.ntweixin.dao.WeixinPublicDao;

@Service
public class WeixinPublicService{
    @Autowired
    private WeixinConf weixinConf;

    private static WeixinPublic weixinPublic;
    @Resource
    private WeixinPublicDao weixinPublicDao;

    public int insert(WeixinPublic pojo){
        return weixinPublicDao.insert(pojo);
    }

    public int insertSelective(WeixinPublic pojo){
        return weixinPublicDao.insertSelective(pojo);
    }

    public int insertList(List<WeixinPublic> pojos){
        return weixinPublicDao.insertList(pojos);
    }

    public int update(WeixinPublic pojo){
        return weixinPublicDao.update(pojo);
    }


    /**
     * 获取微信公众号配置信息
     * @return
     */
    public WeixinPublic getGlobleWeixinPublic(){
        if(weixinPublic==null){
            weixinPublic = weixinPublicDao.getById(weixinConf.getPublicId());
        }

        return weixinPublic;
    }

    public WeixinPublic getById(Long id) {
        return weixinPublicDao.getById(id);
    }
}
